/**
 * Created by WYH on 17/4/22.
 */
angular.module('rentInfo', []).component(
    'rentInfo',
    {
        templateUrl: 'component/rent/rentInfo/rent_info.template.html',
        controller: ['$rootScope', '$scope','Api','$state',"Alert",function ($rootScope,$scope,Api,$state, Alert) {
            $scope.showCanclesRentprotocol =  false;
            $scope.canclesRentprotocol = canclesRentprotocol;
            $scope.makeSureCanclesRentprotocol =  makeSureCanclesRentprotocol;
            $scope.hideCanclesRentprotocol =  hideCanclesRentprotocol;
            $scope.showRentAuthWindow = function () {
                $scope.$parent.showRentAuth=true;
            };

            $scope.showRentCancelAuthWindow = function () {
                $scope.$parent.showRentCancelAuth=true;
            };
            

            function canclesRentprotocol() {
              $scope.showCanclesRentprotocol =  true;
              
            }
            function makeSureCanclesRentprotocol(){
              if($scope.confirmOwnerName == $scope.$parent.companyInfo.companyName){
                Api.cancleRentprotocol($rootScope.id, $scope.$parent.companyInfo.companyName, function (result) {
                  $state.go('company.managerRents')
                });
              }else{
                Alert.alertBox('请检查要终止的企业名称')
              }
              
            
            }
            function hideCanclesRentprotocol(){
              $scope.showCanclesRentprotocol =  false;
            }
            
            
        }]
    }
);